package com.ratp.expertisetechnique;

import com.ratp.bean.Expertise;
import com.ratp.bean.UtilsBean;
import com.ratp.composants.CustomTextWatcher;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

public class SignalementEngageantElec extends Activity {
	private TextView editCircuitElec;
	private TextView editSignalExtElec;
	private TextView editDiversElec;
	private TextView editRampeElec;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.signalement_engageant_elec);
		
		initVariables();
		initEcouteurs();
	}
	/**
	 * INITIALISATION DES VARRIABLES
	 */
	private void initVariables() {
		 editCircuitElec = (EditText) findViewById(R.id.editCircuitElec);
		 editSignalExtElec = (EditText) findViewById(R.id.editSignalExtElec);
		 editDiversElec = (EditText) findViewById(R.id.editDiversElec);
		 editRampeElec = (EditText) findViewById(R.id.editRampeElec);

		Expertise expertise = UtilsBean.getExpertiseInstance();
		
		editCircuitElec.setText(expertise.getCircuitElecMoteurEngage());
		editSignalExtElec.setText(expertise.getSignalisationExtEngage());
		editDiversElec.setText(expertise.getDiversElectEngage());
		editRampeElec.setText(expertise.getRmapePMREngage());
	}
	/**
	 * Methodes pour les listners
	 */
	private void initEcouteurs() {

		editCircuitElec.addTextChangedListener(new CustomTextWatcher() {
			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setCircuitElecMoteurEngage(s.toString());
			}
		});
		editSignalExtElec.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setSignalisationExtEngage(s.toString());
			}
		});
		editDiversElec.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setDiversElectEngage(s.toString());
			}
		});
		editRampeElec.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setRmapePMREngage(s.toString());
			}
		});
	}
}
